home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Inside Mac Games Volume 5 #8
/
IMG 51 Vol 5-8.iso
/
Essentials
/
TCPSerial 1.0.1
/
TCP
/
TCP
next >
Wrap
Text File
|
1996-05-31
|
2KB
|
125 lines
! "MacTCP Serial driver"
@ORIGINATE
@ANSWER
!
@LABEL 1
serreset 57600, 0, 8, 1
setspeed 9600
hsreset 0 0 0 0 0 0
!
! The TCP driver is designed to do everything based on one command. This is
! necessary since commands are executed only at tasks time, and when ARA is
! setting up to answer calls during boot, there may be a very long delay before
! there is any task time. Hence we issue the one command and wait forever.
!
ifANSWER 30
note "Connecting to ^1" 3
!
write "AT*D 'Port 3454' '^1'\13"
matchstr 1 11 "CONNECT\13\10"
matchstr 2 50 "NO CARRIER\13\10"
matchstr 3 50 "ERROR\13\10"
matchstr 4 52 "NO DIALTONE\13\10"
matchstr 5 53 "BUSY\13\10"
matchstr 6 54 "NO ANSWER\13\10"
matchread 1200
jump 59
!
@LABEL 11
note "Communicating via TCP." 3
! Note that we are doing error correction (since TCP is a reliable protocol)
userhook 2
ifstr 6 15 "0"
! Turn off compression. We use the "Ignore Dialtone" flag to control this. It's a kluge,
! but they don't give me anything else I can use.
note "ARA data compression turned off" 1
userhook 3
jump 15
!
@LABEL 15
ifANSWER 16
pause 10
exit 0
!
@LABEL 16
@LABEL 17
exit 0
!
! @ANSWER
! Set up the modem to answer
@LABEL 30
write "AT*D 'Port 3454' ''\13"
!
@LABEL 31
matchstr 1 32 "RING\13\10"
matchstr 2 11 "CONNECT\13\10"
matchstr 3 50 "NO CARRIER\13\10"
matchstr 4 50 "ERROR\13\10"
matchstr 5 52 "NO DIALTONE\13\10"
matchstr 6 53 "BUSY\13\10"
matchstr 7 54 "NO ANSWER\13\10"
matchread 6000
jump 31
!
@LABEL 32
userhook 1
note "Answering phone…" 2
jump 31
!
! 50: error messages
!
@LABEL 50
exit -6021
!
@LABEL 52
exit -6020
!
@LABEL 53
exit -6022
!
@LABEL 54
exit -6023
!
@LABEL 59
exit -6019
!
! Hang up the modem
!
@HANGUP
@LABEL 60
!
! First reset DTR briefly to get the driver to close the connection and go into
! command mode. The first ATH below will wait for the close to complete before returning
! the "OK" response if this works.
!
DTRClear
Pause 1
DTRSet
Pause 1
!
! Try an ATH command. This will wait for the TCPClose from the DTRClear above to finish.
! If it doesn't ever finish, we'll do an ATZ which will call TCPAbort.
!
write "ATH\13"
matchclr
matchstr 1 64 "OK\13\10"
matchstr 2 59 "ERROR\13\10"
matchread 130
!
! ATH finished or didn't work, try ATZ which will do a TCPAbort if the connection is still
! open. This should clean things up.
!
@LABEL 64
write "ATZ\13"
matchclr
matchstr 1 63 "OK\13\10"
matchstr 2 59 "ERROR\13\10"
matchread 60
jump 59
!
@LABEL 63
!
exit 0